package com.dinggao.bangda.interaction;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.dinggao.bangda.R;
import com.dinggao.bangda.data.Logistics;
import com.dinggao.bangda.data.LogisticsAdapter;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/4/13.
 */

public class LogisticsFragment extends Fragment {
    private View view;
    private LogisticsAdapter adapter;
    private RecyclerView recyclerView;
    private List<Logistics> logisticsList = new ArrayList<Logistics>();

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        if (view == null) {
            view = inflater.inflate(R.layout.frag2_logistics, null);
            return view;
        }
        return view;
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
        recyclerView = (RecyclerView) view.findViewById(R.id.recycler_logistics);
        initBean();

        LinearLayoutManager layoutManager = new LinearLayoutManager(getContext());
        recyclerView.setLayoutManager(layoutManager);
        adapter = new LogisticsAdapter(logisticsList);
        recyclerView.setAdapter(adapter);
    }
    // RecyclerView内数据填充
    private void initBean() {
        for (int i = 0; i < 8; i++) {
            Logistics beani = new Logistics();
            beani.setName_logistics((i + 1) + "先生");
            logisticsList.add(beani);
        }
    }
}
